<template>
	<div class="components-container">
         <div>
            <ul class="toolList">
                <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)" :key=index>
                    <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                </li>
            </ul>
        </div>
         <!--数据列表-->
        <dataTable :headList="headList" :dataList="list" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>

        <!-- 修改 | 详情 | 新增 -->
      <department ref="depts" @refreshData="getData"></department>
	</div>

</template>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
</style>
<script>
import apiBase from "@/api/apiBase.js";
import dataTable from "@/components/Table/DataTable";
import staEndUse from "../basic/staEndUse";
import { manage } from "@/mixins/managePage.js";
import { ORDER } from "@/const/orderConst.js";
import department from "./jointDepartmentopen";
const ADD = "新增";
const INFO = "详情";
export default {
  name: "departmentManage",
  mixins: [manage],
  data() {
    return {
      //当前选中行
      currentRow: null,
      list: [],
      selectData: {},
      loading: false,
    };
  },
  methods: {
    //功能操作
    operate(order) {
      this.order = order;
      switch (this.order) {
        case ADD:
          this.$refs.depts.open(this.order);
          break;      
        case INFO:
          this.$refs.depts.open(this.order, this.currentRow.JPDID);
          break;

        default:
      }
    },
  
  
    //获取列项
    getColumns() {
      let data = {};
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Column.GetjointDeptInformationColumns,
        res => {
          this.headList = res.data.content;
        }
      );
    },

    getData() {
      //部门查询
      let data = {};

      apiBase.DoService(data, apiBase.getApiAdress().JointRegConclude.QueryJointDeptInformation, res => {
        this.list = res.data.content.OutData;
        this.pageOrder.totalNum = res.data.content.RecordCount;
      });
    },

   
      //获取当前选中行
    selectRow(row, order) {
      this.currentRow = row;
      // console.log('currentRow',this.currentRow)
      if (order !== "") {
        this.operate(order);
      }
    },


    btnSearch() {
      this.getData();
    },
    btnRepeat() {
      this.selectData = {};
      this.getData();
    }
  },

  mounted() { },
  components: {
    department,
    staEndUse,
    dataTable
  },
  created() {
    this.getColumns();
     this.getData();
  }
};
</script>